<script setup>
import DirChoose from "./components/DirChoosePage.vue";
import FileChoose from "./components/FileChoosePage.vue";
import { Step, Steps, Toast } from "vant";
import { ref } from "vue";

let key=ref("")
let step = ref(0);
let aimDir = ref("");

key.value=window.location.search.slice(1)

function DirChoosed(aim) {
  aimDir.value = aim;
  step.value = 1;
  pageSlide(1);
}

function pageSlide(i) {
  if (aimDir.value === "") {
    Toast("请选择目标文件夹");
    return;
  }
  if (i === 0) {
    document.getElementsByClassName("slideBlock")[0].style.left = "0px";
  } else {
    document.getElementsByClassName("slideBlock")[0].style.left = "-350px";
  }
}

function uploading() {
  step.value = 2;
}
function uploadDone() {
  step.value = 1;
}
</script>

<template>
  <div class="wrapper">
    <Steps :active="step" @click-step="pageSlide">
      <Step>选择目标文件夹</Step>
      <Step>选择文件</Step>
      <Step>上传</Step>
    </Steps>
    <div class="positionBlock">
      <div class="slideBlock">
        <div class="aimDirChoose innerBlock">
          <DirChoose 
          :secretKey="key" 
          @DirChoosed="DirChoosed"
           />
        </div>
        <div class="fileChoose innerBlock">
          <FileChoose 
           :secretKey="key" 
          :aimDir="aimDir" 
          @uploading="uploading" 
          @done="uploadDone" />
        </div>
      </div>
    </div>
  </div>
</template>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 20px;
}
.wrapper {
  width: 350px;
  margin: auto;
}
.positionBlock {
  width: 100%;
  /* background-color: aqua; */
  overflow: hidden;
}
.innerBlock {
  width: 50%;
  float: left;
}
.slideBlock {
  width: 200%;
  position: relative;
  transition: left 0.2s ease-in-out;
  left: 0;
}
.aimDirChoose {
  background-color: azure;
}
</style>
